using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;

public class Chapter04_1_11_ClickEvent : MonoBehaviour, IPointerClickHandler
{
    TextMeshProUGUI textMeshProUGUI;

    private void Start()
    {
        textMeshProUGUI = GetComponent<TextMeshProUGUI>();
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        var linkIndex = TMP_TextUtilities.FindIntersectingLink(textMeshProUGUI, eventData.position, null);
        if (linkIndex != -1)
        {
            var linkInfo = textMeshProUGUI.textInfo.linkInfo[linkIndex];
            Debug.Log($"Link ID: {linkInfo.GetLinkID()}");
        }
    }
}
